home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 8417 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  3.1 KB

  1. Path: gail.ripco.com!mambuhl
  2. From: mambuhl@ripco.com (Martin Ambuhl)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Borland in-line asm
  5. Date: 3 Mar 1996 21:07:08 GMT
  6. Organization: Ripco Communications, Inc.
  7. Message-ID: <4hd1ls$1tj@gail.ripco.com>
  8. NNTP-Posting-Host: golden.ripco.com
  9.  
  10. Bas Broers <B.P.Broers@student.utwente.nl> in
  11. <3139B06E.40C5@student.utwente.nl> asks:
  12.  
  13. >Maybe a simple question, but how can i define a label in BASM (borland in-line
  14. >ssambler).
  15. >For example this program
  16.  
  17. [example snipped]
  18.  
  19. [begin mea culpa]
  20. Before giving an answer, I should note that I am wrong to do so.  The
  21. newsgroup comp.lang.c is for discussion about C.  BASM is a completely
  22. different language and, furthermore, is highly platform-specific.  This
  23. type of question is properly asked in another group, such as
  24. comp.os.msdos.programmer.
  25. [end mea culpa]
  26.  
  27. [begin optional material]
  28. Why do most gcc users know to ask about asm programming in a gnu.* group
  29. or, for dj's dos port, in comp.os.msdos.djgpp, but many Borland and
  30. Microsoft users think comp.lang.c is a dumping ground? The few gcc/djgpp
  31. users who _do_ ask such questions here deserve whatever the bcc, tcc,
  32. msc etc. users dump on them, of course.
  33. [end optional material]
  34.  
  35. Some versions of Borland's compilers come with a file `~/doc/basm.doc';
  36. others include this text in the printed documentation.  Always check
  37. your own documentation before posting. In it, you should have
  38. discovered:
  39.            [from p4]
  40.                     Jump instructions
  41.                     =======================================================
  42.  
  43.                     Jump instructions are treated specially. Since a label
  44.                     cannot be included on the instruction itself, jumps
  45.                     must go to C labels (discussed in "Using jump
  46.                     instructions and labels" on page 8). The allowed jump
  47.                     instructions are given in the next table.
  48.           [from p8]
  49. ------------------  You can use any of the conditional and unconditional
  50.         Using jump  jump instructions, plus the loop instructions, in
  51.   instructions and  inline assembly. They are only valid inside a function.
  52.             labels  Since no labels can be defined in the asm statements,
  53. ------------------  jump instructions must use C goto labels as the object
  54.                     of the jump. If the label is too far away, the jump
  55.                     will be automatically converted to a long-distance
  56.                     jump. Direct far jumps cannot be generated.
  57.           [from p9]
  58.                     In the following code, the jump goes to the C goto
  59.                     label a.
  60.  
  61.                      int     x()
  62.                      {
  63.                      a:                /* This is the goto label "a" */
  64.                         ...
  65.                         asm  jmp  a    /* Goes to label "a" */
  66.                         ...
  67.                      }
  68.  
  69.                     Indirect jumps are also allowed. To use an indirect
  70.                     jump, you can use a register name as the operand of the
  71.                     jump instruction.
  72.        
  73. --
  74. * Martin Ambuhl       net: mambuhl@ripco.com
  75. * Chicago, IL (USA)    
  76.